import request from '@/api/common'
import { ICodeResponse } from '@/types'
import { ref } from 'vue'

export default function useCode () {
  const codeImg = ref<string>('')
  const codeUUid = ref<string>('')

  function handleGetCode () {
    request.setPath('/auth/code').get<ICodeResponse>().then((res) => {
      codeImg.value = res.img
      codeUUid.value = res.uuid
    })
  }

  handleGetCode()

  return {
    handleGetCode,
    codeImg,
    codeUUid
  }
}
